package com.group2.view;
import static model.netBase.IP;
import java.awt.Color;
import javax.swing.*;
import java.awt.Font;
import java.awt.event.*;
import java.net.SocketException;

import model.*;
public class ShopMainFrame_User extends JFrame {

	private String currentName;
	JPanel panel = new JPanel(null);// 第一个JPanel
	Font d = new Font("黑体", Font.BOLD, 25);
	Font f = new Font("黑体", Font.PLAIN, 15);
	Font sm= new Font("黑体", Font.PLAIN, 21);
	JLabel shopicon = new JLabel();
	JLabel smile =new JLabel("(*^▽^*)");
	JLabel intro = new JLabel("苏猫超市欢迎您");
	private Timer timer;
	private JButton reset=new JButton();
	private ShopShowFrame_User ShopShow=null;
	
	// public JFrame index;
	

	public ShopMainFrame_User(String sId, Timer time) throws SocketException {
		currentName=sId;
		timer=time;
		init();
		time.start();
		this.addMouseMotionListener(new MouseMotionListener() {@Override public void mouseDragged(MouseEvent e) {}@Override public void mouseMoved(MouseEvent e) {time.stop();}});
		this.addMouseListener(new MouseListener() {@Override public void mouseClicked(MouseEvent e) {}@Override public void mousePressed(MouseEvent e) {}@Override public void mouseReleased(MouseEvent e) {}@Override public void mouseEntered(MouseEvent e) {time.start();}@Override public void mouseExited(MouseEvent e) {time.start();}});
		JButton reset = new JButton("进入商店");
		reset.setIcon(new ImageIcon(UserLogOnFrame.class.getResource("/images/login.png")));
		reset.setFocusPainted(false);
		reset.setBounds(180, 307, 120, 40);
		reset.setFont(f);
		panel.add(reset);
		reset.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO 自动生成的方法存根
				try {
					ShopShow=new ShopShowFrame_User(sId,time);
					ShopShow.addWindowListener(new WindowListener() {@Override public void windowOpened(WindowEvent e) {time.stop();}@Override public void windowClosing(WindowEvent e) {}@Override public void windowClosed(WindowEvent e) {}@Override public void windowIconified(WindowEvent e) {}@Override public void windowDeiconified(WindowEvent e) {}@Override public void windowActivated(WindowEvent e) {}@Override public void windowDeactivated(WindowEvent e) {}});
				} catch (SocketException ex) {
					throw new RuntimeException(ex);
				}
			}
		});

	}

	private void init() {
		this.setTitle("欢迎来到苏猫超市！");
		this.setResizable(false);
		// 设置框架大小及位置
		this.setSize(500, 500);
		//this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		



		panel.setBounds(0, 0, 500, 500);
		panel.setBackground(Color.white);

		intro.setBounds(150, 200, 220, 50);
		intro.setFont(d);
		panel.add(intro);

		shopicon.setBounds(135,63,250,190);
		shopicon.setIcon(new ImageIcon(UserLogOnFrame.class.getResource("/images/SuMao.png")));
		panel.add(shopicon);
		smile.setBounds(200, 240, 100,73);
		smile.setFont(sm);
		panel.add(smile);
		//panel.setBackground(Color.black);



		this.getContentPane().add(panel);// 将panel放入jframe界面
		this.setVisible(true);
		this.setLocationRelativeTo(null);
	}
}